<?php
namespace BP\Port;

use BP\En\EntityNoName;

require_once("BP/Difference/Handler/PortalInterface.php");
require_once("BP/En/Map.php");
require_once("BP/Tools/Cryptos.php");
require_once("BP/Web/WebUser.php");
class Emp extends EntityNoName {
	protected static $Keys;	// byte[]
	public static function __staticinit() { // static class members
		self::$Keys = 0x12, 0xCD, 0x3F, 0x34, 0x78, 0x90, 0x56, 0x7B;
	}
	public function getHisDept () 
	{
		try 
		{
			return Dept::constructor__String($this->getFK_Dept());
		}
		catch (RuntimeException $ex)
		{
			throw new RuntimeException(((((("@获取操作�?" . $this->getNo()) . "部门[") . $this->getFK_Dept()) . "]出现错误,可能是系统管理员没有给他维护部门.@") . $ex->getMessage()));
		}
	}
	public function getFK_Dept () 
	{
		return $this->GetValStrByKey(EmpAttr::$FK_Dept);
	}
	public function setFK_Dept ($value) // [String value]
	{
		$this->SetValByKey(EmpAttr::$FK_Dept, $value);
	}
	public function getFK_DeptText () 
	{
		return $this->GetValRefTextByKey(EmpAttr::$FK_Dept);
	}
	public function getPass () 
	{
		return $this->GetValStrByKey(EmpAttr::$Pass);
	}
	public function setPass ($value) // [String value]
	{
		$this->SetValByKey(EmpAttr::$Pass, $value);
	}
	public function getSID () 
	{
		return $this->GetValStrByKey(EmpAttr::$SID);
	}
	public function setSID ($value) // [String value]
	{
		$this->SetValByKey(EmpAttr::$SID, $value);
	}
	public function getHisUAC () 
	{
		$uac = new UAC();
		$uac->OpenForAppAdmin();
		return $uac;
	}
	public function CheckPass ($pass) // [String pass]
	{
		if (($SystemConfig->getOSDBSrc() == $OSDBSrc->WebServices))
		{
			$ws = new PortalInterface();
			$IsCheck = $ws->CheckUserNoPassWord($this->getNo(), $pass);
			if (($IsCheck ==  TRUE ))
			{
				return  TRUE ;
			}
			return  FALSE ;
		}
		else
		{
			if (($SystemConfig->getIsEnablePasswordEncryption() ==  TRUE ))
				$pass = $Cryptos->aesDecrypt($pass);
			if ($this->getPass()->equals($pass))
			{
				return  TRUE ;
			}
		}
		return  FALSE ;
	}
	public static function constructor__ () 
	{
		$me = new self();
		return $me;
	}
	public static function constructor__String ($no) // [String no]
	{
		$me = new self();
		if ((($no . NULL) . ($no->length() == 0)))
		{
			throw new RuntimeException("@要查询的操作员编号为空�??");
		}
		$me->setNo($no->trim());
		try 
		{
			$me->Retrieve();
		}
		catch (RuntimeException $ex)
		{
			if (($BP->Sys->SystemConfig->getOSDBSrc() == $OSDBSrc->Database))
			{
				$obj = new QueryObject($me);
				$obj->AddWhere(EmpAttr::$No, $no);
				$i = $obj->DoQuery();
				if (($i == 0))
				{
					$i = $me->RetrieveFromDBSources();
				}
				if (($i == 0))
				{
					throw new RuntimeException(((("@用户或�?�密码错误：[" . $no) . "]，或者帐号被停用。@�?术信�?(从内存中查询出现错误)：ex1=") . $ex->getMessage()));
				}
			}
			else
			{
				throw $ex;
			}
		}
		return $me;
	}
	public function getEnMap () 
	{
		if (($this->get_enMap() != NULL))
		{
			return $this->get_enMap();
		}
		$map = new Map();
		$map->setEnDBUrl(new DBUrl($DBUrlType->AppCenterDSN));
		$map->setPhysicsTable("Port_Emp");
		$map->Java_SetDepositaryOfMap($Depositary->Application);
		$map->Java_SetDepositaryOfEntity($Depositary->Application);
		$map->setEnDesc("用户");
		$map->Java_SetEnType($EnType->App);
		$map->IndexField = EmpAttr::$FK_Dept;
		$map->AddTBStringPK(EmpAttr::$No, NULL, "编号",  TRUE ,  FALSE , 1, 20, 30);
		$map->AddTBString(EmpAttr::$Name, NULL, "名称",  TRUE ,  FALSE , 0, 200, 30);
		$map->AddTBString(EmpAttr::$Pass, "123", "密码",  FALSE ,  FALSE , 0, 20, 10);
		$map->AddDDLEntities(EmpAttr::$FK_Dept, NULL, "部门", Depts::constructor__(),  TRUE );
		$map->AddTBString(EmpAttr::$SID, NULL, "安全校验�?",  FALSE ,  FALSE , 0, 36, 36);
		$map->AddSearchAttr(EmpAttr::$FK_Dept);
		$this->set_enMap($map);
		return $this->get_enMap();
	}
	public function getGetNewEntities () 
	{
		return Emps::constructor__();
	}
	public function ResetPass () 
	{
		return "执行成功.";
	}
	public function ChangePass ($oldpass, $pass1, $pass2) // [String oldpass, String pass1, String pass2]
	{
		if (!$this->getNo()->equals($WebUser->getNo()))
		{
			return "err@sss";
		}
		return "执行成功.";
	}
}
Emp::__staticinit(); // initialize static vars for this class on load
?>
